package com.aegis.core.manager;

import com.aegis.core.dao.AegisDao;

/**
 * @Author wuweixin
 *
 * @Version 1.0
 * @Descritube 管理需要的satoken组件
 */
public class AegisComponentManager {

    private static AegisDao aegisDao;

    private AegisComponentManager() {
        throw new UnsupportedOperationException("Cannot instantiate class SaComponentManager");
    }

    /**
     * 初始化aegisDao
     *
     * @param aegisDao
     */
    public static void initAegisDao(AegisDao aegisDao) {
        if (AegisComponentManager.aegisDao == null) {
            synchronized (AegisComponentManager.class) {
                if (AegisComponentManager.aegisDao == null) {
                    AegisComponentManager.aegisDao = aegisDao;
                }
            }
        }
    }

    /**
     * @return
     */
    public static AegisDao getAegisDao() {
        if (aegisDao == null) {
            throw new RuntimeException("saDao not init");
        }
        return aegisDao;
    }


}
